﻿using FFmpeg.AutoGen;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FFmpegWinui3.UlitFolder
{
    internal static class FFmpegBinariesHelper
    {
        /// <summary>
        /// 注册库文件
        /// </summary>
        internal static void RegisterFFmpegBinaries()
        {
            //获取当前软件目录
            var current = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            var probe = Path.Combine("FFmpeg", "bin", Environment.Is64BitOperatingSystem ? "x64" : "x86");

            while (current != null)
            {
                var ffmpegBinaryPath = Path.Combine(current, probe);
                if (Directory.Exists(ffmpegBinaryPath))
                {
                    ffmpeg.RootPath = ffmpegBinaryPath;
                    return;
                }
                current = Directory.GetParent(current)?.FullName;
            }

            ffmpeg.avdevice_register_all();
        }

    }
}
